class Set { private int n1,n2,n3; public int sum() { int s=n1+n2+n3; return s; } public double mean() { double m=sum()/3.0; return m; } public void setData(int x,int y,int z) { n1=x;n2=y;n3=z; } } class demo { public static void main(String args[]) { Set a,b; a=new Set(); b=new Set(); a.setData(4,5,7); b.setData(10,20,25); int z=a.sum()+b.sum(); System.out.println("Total sum is "+z); System.out.println("Mean of b is "+b.mean()); } }
Total Sum is 71 Mean of b is 18.333333